/**
 * @file icon-button
 * @author liaoxuezhi@baidu.com
 */
/* eslint fecs-indent: [0, "space", 2, 2] */

import * as React from 'react';
import {
  PureComponent,
  PropTypes
} from 'react';
import {Renderer, render, renderChildren} from './renderer';
import * as cx from 'classnames';
import * as CustomPropTypes from './propTypes';
import * as omit from 'lodash/omit';
import * as pick from 'lodash/pick';
import * as assign from 'object-assign';
import {
  Row,
  Col
} from 'react-bootstrap';
import * as schema from './wrapper-schema.json';

@Renderer({
  name: 'wrapper',
  desc: '...',
  test: (path, config) => /(?:^|\/)wrapper$/.test(path),
  schema
})
export default class WrapperRenderer extends PureComponent {
  static propTypes = {
    className: PropTypes.string,
    body: PropTypes.any,
    data: PropTypes.any
  };

  static defaultProps = {
    className: 'bg-white',
    size: ''
  };

  render() {
    const {
      className,
      title,
      data,
      body,
      $path,
      size
    } = this.props;

    const childProps = assign({}, omit(this.props, ['$path', 'body', 'className']), {
      data
    });

    return (
      <div
        className={cx(`wrapper${size ? `-${size}` : ''}`, className)}
      >
        {body ? renderChildren($path, body, childProps) : null}
      </div>
    );
  }
}
